#include "HermiteInterpolation.hpp"
#include <iostream>
#include <vector>

int main() {
    std::vector<double> times = {0, 3, 5, 8, 13, 0, 3, 5, 8, 13};
    std::vector<double> values = {0, 225, 383, 623, 993, 75, 77, 80, 74, 72};
    std::vector<int> exp = {0, 0, 0, 0, 0, 1, 1, 1, 1, 1};

    // 创建 Hermite 插值对象
    HermiteInterpolation hermite(times, values, exp);

    // 预测 t = 10 秒的位置
    double predicted_position = hermite(10);
    std::cout << "Predicted position at t = 10 seconds: " << predicted_position << " feet" << std::endl;

    // 预测 t = 10 秒的速度
    double predicted_velocity = hermite.derivative(10);
    std::cout << "Predicted velocity at t = 10 seconds: " << predicted_velocity << " feet/second" << std::endl;

    // 检查是否超过速度限制
    for (auto i=0.0; i<13.0; i+=0.01)
    {
        if (hermite.derivative(i) > 81.0)
        {
            std::cout << "Predicted velocity at t = "<< i <<" seconds: " << hermite.derivative(i) << " feet/second" << std::endl;
            std::cout << "The car exceed the speed limit." << std::endl;
            break;
        }
        if (i>=13.0){
            std::cout << "The car does not exceed the speed limit." << std::endl;
        }
    }

    return 0;
}

